import 'dart:ffi';

import 'package:app_admin/models/order_plan_info.dart';
import 'package:app_admin/models/order_set_info.dart';
import 'package:app_admin/models/user_full_info.dart';
import 'package:app_admin/utils/apis.dart';
import 'package:app_admin/utils/logger.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

///数据
class DataController extends GetxController {
  ///玩家信息
  late Rx<UserFullInfo> userInfo;

  ///订单设置信息
  late Map<String, OrderSetInfo> orderSets;

  ///订单计划
  late Map<String, OrderPlanInfo> orderPlan;

  @override
  void onInit() async {
    super.onInit();

    WidgetsBinding.instance.addPostFrameCallback((timeStamp) => _init());
  }

  ///初始化数据
  void _init() async {}

  ///登录
  Future login(String userID, String token) async {
    // try {
    //   var user = await OpenIM.iMManager.login(
    //     userID: userID,
    //     token: token,
    //     defaultValue: () async => UserInfo(userID: userID),
    //   );
    //   userInfo = UserFullInfo.fromJson(user.obs.toJson()).obs;
    //   _queryMyFullInfo();
    //   _queryAtAllTag();
    // } catch (e, s) {
    //   Logger.print('e: $e  s:$s');
    //   await _handleLoginRepeatError(e);
    //   rethrow;
    // }
  }

  ///查询所有订单设置
  void queryAllOrderSet() async {
    // final data = await Apis.queryMyFullInfo();
    // if (data is UserFullInfo) {
    //   userInfo.update((val) {
    //     val?.allowAddFriend = data.allowAddFriend;
    //     val?.allowBeep = data.allowBeep;
    //     val?.allowVibration = data.allowVibration;
    //     val?.nickname = data.nickname;
    //     val?.faceURL = data.faceURL;
    //     val?.phoneNumber = data.phoneNumber;
    //     val?.email = data.email;
    //     val?.birth = data.birth;
    //     val?.gender = data.gender;
    //   });
    // }
  }

  ///查询所有订单生产计划
  void queryAllOrderPlanInfo() async {}
}
